<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>提示</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style type="text/css">
        html,
        body {
            height: 100%;
            margin: 0
        }

        .header_return {
            background-image: url(../image/we_return.png);
            background-repeat: no-repeat;
            background-size: 18px 23px;
            background-position: center;
            width: 45px;
            height: 100%;
            display: block;
        }

        .header_context {
            font-size: 18px;
            color: #fff;
            text-align: center;
            line-height: 45px;
            -webkit-box-flex: 1.0;
            display: block;
        }

        .header_right {
            width: 11%;
            height: 100%;
            display: block;
        }
    </style>
</head>

<body>

    <header style="width:100%;height:65px;background-color:#ff9900">
        <div class="header_div" style="height:45px;display:-webkit-box;padding-top:20px;">
            <div class="header_return"></div>
            <div class="header_context">提示</div>
            <div class="header_right"></div>
        </div>
    </header>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript" src="../script/common.js"></script>

<script type="text/javascript">
    var mType;
    apiready = function() {
        mType = api.pageParam.type
        var divContext = document.getElementsByClassName('header_context')[0];
        console.log('.....type......' + mType)
        switch (mType) {
            case 1: //去加载购买
                divContext.innerText = '套餐'
                var url = common.appConstant.linxTheserverIp + common.keyword.vipdeposit
                var vipId = $api.getStorage(common.appKey.vipId)
                var comboId = $api.getStorage(common.appKey.comboId)
                var good_tab = $api.getStorage(common.appKey.good_tab);
                var pledge = $api.getStorage(common.appKey.pledge);
                var siteAreaid = $api.getStorage(common.appKey.siteAreaid);
                getOpenFrame('prompt_frame', url + '?userid=' + $api.getStorage(common.appKey.userId) + '&vipid=' + vipId + '&pattern=' + $api.getStorage(common.appKey.pattern) + '&appType=2&comboid=' + comboId + '&good_tab=' + good_tab+'&statu='+pledge+'&siteAreaid='+siteAreaid);
                break;
            case 2: //提醒
                getOpenFrame('prompt_frame', './prompt_frame.html');

                break;
            default:

        }
        $('.header_return').click(function() {
            getBack()
        })

        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
             getBack()
        });

    };

    function getBack(){
      if(mType == 1){
        api.sendEvent({
          name: 'indexFrame_Event',
          extra: {
            type:2
         }
        });
      }
      api.closeWin({});
    }

    //打开 openFrame
    function getOpenFrame(name, url) {
        console.log('..url..' + url);
        api.openFrame({
            name: name,
            url: url,
            rect: {
                x: 0,
                y: getFrameY(),
                w: api.winWidth,
                h: 'auto'
            },
            pageParam: {
                name: 'test'
            },
            bounces: true,
            bgColor: 'rgba(255,255,255,1)',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true,
            progress: {
                type:'page',
                color: "#f52929"
            }
        });
    }

    function getFrameY() {
        var frameheigh = $api.dom('header').offsetHeight;
        var systemType = api.systemType;
        if (api.systemType === 'ios') {
            var systemVersion = api.systemVersion;
            if (parseFloat(systemVersion) >= 11.0) {
                frameheigh = frameheigh + 20;
            }
            return frameheigh;
        }
        return frameheigh;
    }
</script>

</html>
